package com.moonshineproject.plugin.haxe.haxeproject.vo
{
	import __AS3__.vec.Vector;
	
	import com.moonshineproject.plugin.actionscript.as3project.settings.PathListSetting;
	import com.moonshineproject.plugin.actionscript.as3project.vo.SWFOutputVO;
	import com.moonshineproject.plugin.haxe.haxeproject.exporter.HaxeFlashDevelopExporter;
	import com.moonshineproject.plugin.project.vo.ProjectVO;
	import com.moonshineproject.plugin.settings.vo.BooleanSetting;
	import com.moonshineproject.plugin.settings.vo.ColorSetting;
	import com.moonshineproject.plugin.settings.vo.ISetting;
	import com.moonshineproject.plugin.settings.vo.IntSetting;
	import com.moonshineproject.plugin.settings.vo.SettingsWrapper;
	import com.moonshineproject.plugin.settings.vo.StringSetting;
	
	import flash.filesystem.File;
	
	public class HaXeProjectVO extends ProjectVO
	{
		public var projectName:String;
		
		public var swfOutput:SWFOutputVO = new SWFOutputVO();
		public var buildOptions:HaxeBuildOptions = new HaxeBuildOptions();
		
		public var classpaths:Vector.<File> = new Vector.<File>();
		public var libraries:Vector.<File> = new Vector.<File>();
		public var haxelib:Vector.<File> = new Vector.<File>();
		public var assetLibrary:XMLList; // TODO Unknown if it works in FD, there just for compatibility purposes (<library/> tag)
		public var targets:Vector.<File> = new Vector.<File>();
		public var hiddenPaths:Vector.<File> = new Vector.<File>();
		public var showHiddenPaths:Boolean = false;
		
		public var prebuildCommands:String;
		public var postbuildCommands:String;
		public var postbuildAlways:Boolean;
		
		public var testMovie:String = "Default";
		public var testMovieCommand:String;

		public function HaXeProjectVO(folder:File)
		{
			super(folder);
		}
		
		override public function getSettings():Vector.<SettingsWrapper>
		{
			var settings:Vector.<SettingsWrapper> = Vector.<SettingsWrapper>([
				new SettingsWrapper("Output", 
					Vector.<ISetting>([
						new IntSetting(swfOutput,	"frameRate", 	"Framerate (FPS)"),
						new IntSetting(swfOutput,	"width", 		"Width"),
						new IntSetting(swfOutput,	"height",	 	"Height"),
						new ColorSetting(swfOutput,	"background",	"Background color"),
						new IntSetting(swfOutput,	"swfVersion",	"Minimum player version")
					])
				),
				new SettingsWrapper("Build options", 
					Vector.<ISetting>([
						new StringSetting(buildOptions, 	"additional", 	"Additional compiler arguments"),
						new StringSetting(buildOptions, 	"directives", 	"Directives"),
						new StringSetting(buildOptions, 	"mainClass", 	"Main class"),
						new BooleanSetting(buildOptions, 	"overRide", 	"Override"),
						new BooleanSetting(buildOptions,	"flashStrict",	"Flash Strict"),
						new BooleanSetting(buildOptions,	"verbose",		"Verbose")
					])
				),
				new SettingsWrapper("Paths", 
					Vector.<ISetting>([
						new PathListSetting(this, 		"targets",	"Compile targets", folder, true, false),
						new PathListSetting(this, 		"haxelib", 		"HaXe libraries", folder, true, false),
						new PathListSetting(this, 		"classpaths",	"Class paths", folder, false)
					])
				)
			]);
			
			return settings;
		}
		
		override public function saveSettings():void
		{
			// Write settings
			HaxeFlashDevelopExporter.export(this, projectFile);
		}
		
	}
}